/*     */ package com.umeng.newxp.common;
/*     */ 
/*     */ import android.content.ContentValues;
/*     */ import android.content.Context;
/*     */ import android.database.Cursor;
/*     */ import android.database.SQLException;
/*     */ import android.database.sqlite.SQLiteDatabase;
/*     */ import android.database.sqlite.SQLiteOpenHelper;
/*     */ import com.umeng.common.Log;
/*     */ 
/*     */ public class e
/*     */ {
/*     */   public static final String a = "key";
/*     */   public static final String b = "value";
/*     */   public static final String c = "_id";
/*     */   private static final String d = "Preferences";
/*     */   private static final String e = "create table settings (_id integer primary key autoincrement, key text not null, value text not null);";
/*     */   private static final String f = "data";
/*     */   private static final String g = "settings";
/*     */   private static final int h = 1;
/*     */   private Context i;
/*     */   private a j;
/*     */   private SQLiteDatabase k;
/*  30 */   private static e l = null;
/*     */ 
/*     */   private e(Context paramContext)
/*     */   {
/*  54 */     this.i = paramContext;
/*     */   }
/*     */ 
/*     */   public e a() throws SQLException {
/*  58 */     this.j = new a(this.i);
/*  59 */     this.k = this.j.getWritableDatabase();
/*  60 */     return this;
/*     */   }
/*     */ 
/*     */   public void b() {
/*  64 */     this.j.close();
/*     */   }
/*     */ 
/*     */   public String a(String paramString) {
/*  68 */     a();
/*  69 */     String str = null;
/*  70 */     Cursor localCursor = this.k.query("settings", new String[] { "key", "value" }, "key=?", new String[] { paramString }, null, null, null);
/*  71 */     if ((localCursor != null) && (localCursor.getCount() > 0)) {
/*  72 */       localCursor.moveToFirst();
/*  73 */       str = localCursor.getString(1);
/*  74 */       localCursor.close();
/*     */     }
/*  76 */     b();
/*  77 */     return str;
/*     */   }
/*     */ 
/*     */   public String a(String paramString1, String paramString2) {
/*  81 */     String str = a(paramString1);
/*  82 */     if ((str == null) || ("".equals(str))) {
/*  83 */       return new String(paramString2);
/*     */     }
/*  85 */     return str;
/*     */   }
/*     */ 
/*     */   public boolean b(String paramString1, String paramString2)
/*     */   {
/*  90 */     a();
/*  91 */     Cursor localCursor = this.k.query("settings", new String[] { "key", "value" }, "key=?", new String[] { paramString1 }, null, null, null);
/*     */     ContentValues localContentValues;
/*     */     boolean bool;
/*  93 */     if ((localCursor != null) && (localCursor.getCount() > 0)) {
/*  94 */       localCursor.close();
/*  95 */       localContentValues = new ContentValues();
/*  96 */       localContentValues.put("key", paramString1);
/*  97 */       localContentValues.put("value", paramString2);
/*  98 */       bool = this.k.update("settings", localContentValues, "key= ?", new String[] { paramString1 }) > 0;
/*     */     }
/*     */     else {
/* 101 */       if (localCursor != null) {
/* 102 */         localCursor.close();
/*     */       }
/* 104 */       localContentValues = new ContentValues();
/* 105 */       localContentValues.put("key", paramString1);
/* 106 */       localContentValues.put("value", paramString2);
/* 107 */       bool = this.k.insert("settings", null, localContentValues) != -1L;
/*     */     }
/* 109 */     b();
/* 110 */     return bool;
/*     */   }
/*     */ 
/*     */   public boolean a(String paramString, boolean paramBoolean) {
/* 114 */     String str = a(paramString);
/* 115 */     if (str == null)
/* 116 */       return paramBoolean;
/* 117 */     if ("true".equals(str)) {
/* 118 */       return true;
/*     */     }
/* 120 */     return false;
/*     */   }
/*     */ 
/*     */   public boolean b(String paramString) {
/* 124 */     String str = a(paramString);
/* 125 */     if (str == null)
/* 126 */       return false;
/* 127 */     if ("true".equals(str)) {
/* 128 */       return true;
/*     */     }
/* 130 */     return false;
/*     */   }
/*     */ 
/*     */   public boolean b(String paramString, boolean paramBoolean) {
/* 134 */     return b(paramString, paramBoolean ? "true" : "false");
/*     */   }
/*     */ 
/*     */   public static e a(Context paramContext) {
/* 138 */     if (l == null) {
/* 139 */       l = new e(paramContext.getApplicationContext());
/*     */     }
/* 141 */     return l;
/*     */   }
/*     */ 
/*     */   private class a extends SQLiteOpenHelper
/*     */   {
/*     */     public a(Context arg2)
/*     */     {
/*  35 */       super("data", null, 1);
/*     */     }
/*     */ 
/*     */     public void onCreate(SQLiteDatabase paramSQLiteDatabase)
/*     */     {
/*  40 */       paramSQLiteDatabase.execSQL("create table settings (_id integer primary key autoincrement, key text not null, value text not null);");
/*     */     }
/*     */ 
/*     */     public void onUpgrade(SQLiteDatabase paramSQLiteDatabase, int paramInt1, int paramInt2)
/*     */     {
/*  45 */       Log.e("Preferences", "Upgrading database from version " + paramInt1 + " to " + 
/*  46 */         paramInt2 + ", which will destroy all old data");
/*  47 */       paramSQLiteDatabase.execSQL("DROP TABLE IF EXISTS settings");
/*  48 */       onCreate(paramSQLiteDatabase);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\umeng_sdk.jar
 * Qualified Name:     com.umeng.newxp.common.e
 * JD-Core Version:    0.6.2
 */